package com.yueya.config;

import com.jfinal.kit.StrKit;
import com.yueya.basic.dict.model.Dict;

public class GlobalParam {

	private static final String KEY_TOKEN_EXPIRE = "key_token_expire";// token超时时间
	private static final String ATTACHMENT_URL = "attachment_url";// 附件访问base url
	private static final String ATTACHMENT_UPLOAD_SAVE_PATH = "attachment_upload_save_path";// 附件保存绝对路径

	/**
	 * 获取Token的有效期时长（毫秒）,默认为：5天
	 * 
	 * @return
	 */
	public static long getTokenExpire() {
		String value = Dict.dao.getValue(KEY_TOKEN_EXPIRE);
		if (StrKit.isBlank(value))
			return 5 * 24 * 60 * 60 * 1000L;
		return Long.valueOf(value) * 24 * 60 * 60 * 1000L;
	}

	/**
	 * 获取附件仿问BASE URL
	 * 
	 * @return
	 */
	public static String getAttUrl() {
		String url = Dict.dao.getValue(ATTACHMENT_URL);
		return StrKit.notBlank(url) ? url.trim() : "";
	}
	
	/**
	 * 获取附件保存绝对路径
	 * 
	 * @return
	 */
	public static String getAttUploadSavePath() {
		String path = Dict.dao.getValue(ATTACHMENT_UPLOAD_SAVE_PATH);
		return StrKit.notBlank(path) ? path.trim() : "";
	}
	
	
}
